#include "process.h"

#define NUM 101
#define STYLE '='
#define POINT '.'
#define SPACE ' '

const int pnum = 3;

void Process(double total,double current)
{
    //1.更新当前百分比
    double rate = (current / total)*100;

    //2.更新进度条主体
    char bar[NUM];//每1%跟新一次进度条
    memset(bar,'\0',sizeof(bar));//初始化
    for(int i= 0 ;i < (int)rate;i++)
    {
        bar[i] = STYLE;
    }

    //3.更新旋转光标的形态:以点的形式
    static int num = 0;
    num++;

    char points[pnum+1];
    memset(points,'\0',pnum+1);
    for(int i = 0; i<pnum;i++)
    {
        if(i < num) points[i] = POINT;
        else points[i] = SPACE;
    }

    //4.打印
    printf("[%-100s][%.1lf%%]%s\r",bar,rate,points);

}
